package io.gitee.chearnee.fw.common.component;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import io.gitee.chearnee.fw.common.model.IBaseEnum;
import io.gitee.chearnee.fw.common.utils.JacksonEnumUtils;

import java.io.IOException;

public final class BaseEnumSerializer extends StdSerializer<IBaseEnum> {

  public BaseEnumSerializer() {
    this(null);
  }

  private BaseEnumSerializer(Class<IBaseEnum> t) {
    super(t);
  }

  @Override
  public void serialize(IBaseEnum value, JsonGenerator gen, SerializerProvider provider)
      throws IOException {
    JacksonEnumUtils.writeObject(gen, value);
  }
}
